'use strict';

var React = require('react-native');

var {
  ActivityIndicatorIOS,
  StyleSheet,
  View
} = React;

var TimerMixin = require('react-timer-mixin');

var LoadingView = React.createClass({
  mixins:[TimerMixin],
  getInitialState:function(){
    return {
      animating:true
    }
  },
  setToggleTimeout:function(){
    this.setTimeout(
      () => {
        this.setState({animating:!this.state.animating});
        this.setToggleTimeout();
      },
      1200
    );
  },
  componentDidMount:function(){
    this.setToggleTimeout();
  },
  render:function(){
    return (
      <View>
        <ActivityIndicatorIOS 
            animating={this.state.animating} 
            style={[styles.centering, {height:80}]} 
            size="large" />
      </View>
    );
  }
});

var styles = StyleSheet.create({
  centering: {
    alignItems: 'center',
    justifyContent: 'center',
    marginTop:65
  }
});

module.exports = LoadingView; 